package day06test;

import java.util.Calendar;
import java.util.Random;

public class MaxOfArray {
    public static void main(String[] args) {
        int[] arr = arr(5);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

    public static int[] arr(int len) {
        Random r = new Random();
        int[] arr = new int[len];
        for (int i = 0; i < arr.length; i++) {
            int randomNumber = r.nextInt(100) + 1;
            arr[i] = randomNumber;

        }
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        int[] result = new int[len + 1];
        System.arraycopy(arr, 0, result, 0, arr.length);
        result[result.length - 1] = max;
        return result;
    }
}

